<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-cache, must-revalidate">

    <!--必要样式-->
    <link href="index_data/styles.css" rel="stylesheet" type="text/css">
    <link href="index_data/demo.css" rel="stylesheet" type="text/css">
    <script src="index_data/jquery-2.js"></script>
</head>
<body>
<canvas class="pg-canvas" width="1920" height="889"></canvas>
<div class="login">
    <div class="login_title" style="text-align: center">

    </div>
    <div class="login_fields">
        <div class="login_fields__user">
            <div class="icon">
                <img alt="" src="index_data/user_icon_copy.png">
            </div>
            <input name="login" placeholder="用户名" maxlength="16" class="username" id="contact-email" autocomplete="off" type="text">
            <div class="validation">
                <img alt="" src="index_data/tick.png">
            </div>
        </div>
        <div class="login_fields__password">
            <div class="icon">
                <img alt="" src="index_data/lock_icon_copy.png">
            </div>
            <input  class="passwordNumder" placeholder="密码" maxlength="16" id="contact-subject" name="subject" autocomplete="off" type="password">
            <div class="validation">
                <img alt="" src="index_data/tick.png">
            </div>
        </div>
        <div class="login_fields__password">
            <div class="icon">
                <img alt="" src="index_data/lock_icon_copy.png">
            </div>
            <input  class="passwordNumder" placeholder="验证码" maxlength="6" id="contact-authCode" name="authCode" autocomplete="off" type="text">
            <div class="validation">
                <img alt="" src="index_data/tick.png">
            </div>
        </div>

        <div class="login_fields__submit">
            <input value="登录" type="button" onclick="login()">
        </div>
    </div>
    <div class="success"> </div>
</div>

<script src="../static/layui/layer/layer.js"></script>
<script src="index_data/Particleground.js" type="text/javascript"></script>
<script src="index_data/controlLogin.js" type="text/javascript"></script>
<script src="../js/common/util.js"></script>
<script src="../js/common/jquery.base64.js"></script>
<div class="layui-layer-move"></div>
</body>


<script>
    $(function () {
        $("input[name='subject']").val('');
    });
</script>

<script>
    function login() {
        var account = $("#contact-email").val();
        var pwd = $("#contact-subject").val();
        var authCode = $("#contact-authCode").val();

        var bo = false;
        var msg = "";
        if(!checkData(account)){
            msg += "用户名不能为空，"; bo = true;
        }
        if(!checkData(pwd)){
            msg += "密码不能为空，"; bo = true;
        }
        if(!checkData(authCode)){
            msg += "验证码不能为空，"; bo = true;
        }

        if(bo){
            msg = msg.substr(0, msg.length - 1);
            lay_msg(msg); return;
        }


        var url = '/webUserCtrl/login';
        pwd = encode(pwd);
        pwd = $.base64.encode(pwd + 'hwan-game');
        var data = {"account": account,"pwd": pwd, authCode: authCode};
        var res = reqByAjaxGetAsync(url, data);
        if(!checkData(res)){
            alert("网络异常");
        }else{
            if(res.body.code == '200'){
                var web_user = res.body.content;
                if(checkData(web_user)){
                    localStorage.setItem("user",web_user);
                    // sessionStorage.setItem("user",web_user);
                }
                // window.location.href = "../index.html#/index";
                window.location.href = "../html/index.html#/index";
            }else{
                alert(res.body.info);
            }
        }
    }
</script>
</html>